"""
语法:
    presence_of_element_located(locator)
        - locator:定位器, 元组类型(元素定位方法,方法对应的值):
        (By.ID, "ID属性值")
        (By.NAME, "NAME属性值")
        (By.PARTIAL_LINK_TEXT, "部分文本值")
        (By.XPATH, "XPATH表达式")
        (By.CSS_SELECTOR, "CSS选择器")
"""

# 1. 导入需要的包
from time import sleep
from  selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

# 2.创建浏览器对象, 并打开指定网页
driver = webdriver.Chrome()
driver.maximize_window()
driver.get("http://www.baidu.com")

# 3.元素定位+元素操作
locator = (By.ID, "kw")
search = EC.presence_of_element_located(locator)(driver)

search.send_keys("EC模块")

# 4. 关闭浏览器
sleep(3)
driver.quit()
